package com.zzh.other;

import android.content.Context;
import android.content.Intent;

import com.zzh.net.Utils.ToastUtils;

public class IntentJump {

    private static final String SKIP_MAIN = "com.zzh.rack.MainActivity";
    private static final String SKIP_WEB = "com.zzh.web.WebActivity";

    public static boolean skip(Context context) {
        if (isCalss(SKIP_MAIN)) {
            go(context, SKIP_MAIN);
            return true;
        } else if (isCalss(SKIP_WEB)) {
            go(context, SKIP_WEB);
            return true;
        }
        ToastUtils.show("没有找到对应的类");
        return false;
    }

    private static boolean isCalss(String classStr) {
        try {
            Class.forName(classStr);
            return true;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            return false;
        }
    }


    private static void go(Context context, String skip) {
        Intent intent = new Intent();
        intent.setAction(skip);
        context.startActivity(intent);
    }

}
